/*		
showAjaxMsg : function(data, successHandle) {
		var code = data.result;
		if (code == 1) {

		}
	},
 */
(function($){
	$.custom = {
		treeTask : function(options) {
			var settings = {
				url:'',
				callback:null
			};
			options = $.extend(settings,options);
			$.ajax({
				url:options.url,
				type:'POST',
				dataType:'JSON',
				success:function(data) {
					var _r = $.custom.list2Tree(data,1);
					if(settings.callback!=null)
						settings.callback(_r);
				}
			});
		},
		list2Tree : function(data,rootId) {//必定要有的两个属性为id与pid
			var _r = new Array();
			for(var i=0; i<data.length; i++) {
				var o = data[i];
				if(o.pid==rootId) {
					o.children = o.children.concat($.custom.list2Tree(data,o.id));
					if(o.children=='')
						o.children = undefined;
					_r.push(o);
				}
			}
			return _r;
		}
	},
	
	$.Dialog = {
		open : function(options) {
			var settings = {
				timeout : null
			};
			var options = $.extend(settings, options);

			var d = $.ligerDialog.open(options);

			if (options.timeout != null) {
				setTimeout(function() {
					d.close();
				}, options.timeout);
			}
			return d;
		},
		tip : function(options) {
			options = $.extend({
				showType: 'slide',
				width: 240,
				modal: false,
				height: 100,
				type:'none' 
			}, options||{});
			
			$.extend(options, {
	            fixedType: 'se',
	            isDrag: false,
	            isResize: false,
	            showMax: false,
	            showToggle: false,
	            showMin: false
	        });
	        return $.Dialog.open(options);
		}
	},
	$.fn.tip = function(options) {
		this.each(function() {
			var p = $.extend({}, $.ligerDefaults.ElementTip, options || {});
            p.target = p.target || this;
            //如果是自动模式：鼠标经过时显示，移开时关闭
            if (p.auto || options == undefined)
            {
                if (!p.content)
                {
                    p.content = this.title;
                    if (p.removeTitle)
                        $(this).removeAttr("title");
                }
                p.content = p.content || this.title;
                $(this).bind('mouseover.tip', function ()
                {
                    p.x = $(this).offset().left + (p.distanceX || 0);
                    p.y = $(this).offset().top + (p.distanceY || 0);
                    $.ligerTip(p);
                }).bind('mouseout.tip', function ()
                {

                    var tipmanager = $.ligerui.managers[this.ligeruitipid];
                    if (tipmanager)
                    {
                        tipmanager.remove();
                    }
                });
            }
            else
            {
                if (p.target.ligeruitipid) return;
                p.x = $(this).offset().left + (p.distanceX || 0);
                p.y = $(this).offset().top + (p.distanceY || 0);
                p.x = p.x || 0;
                p.y = p.y || 0;
                $.ligerTip(p);
            }
		})
		return $.ligerui.get(this, 'ligeruitipid');
	}
})(jQuery);
	/*
	 * $.Dialog.open = function(options) { var settings = { timeout:null } var
	 * options = $.extend(settings,options)
	 * 
	 * var d = $.ligerDialog.open(options);
	 * 
	 * if(options.timeout!=null) { setTimeout(function() { d.close();
	 * },options.timeout); } }
	 */

/*
 * openDialog.tip : function(options) { );
 * 
 * options = $.extend(options, { fixedType: 'se', isDrag: false, isResize:
 * false, showMax: false, showToggle: false, showMin: false });
 * 
 * //openDialog(options); }
 */
// 自定义JQuery函数
/*
 * (function($) { $.extend($.fn, { // 将表单对象序列化成JSON serializeJson : function() {
 * var serializeObj = {}; var array = this.serializeArray(); $(array).each(
 * function() { if (serializeObj[this.name]) { if
 * ($.isArray(serializeObj[this.name])) { serializeObj[this.name]
 * .push(this.value); } else { serializeObj[this.name] = [
 * serializeObj[this.name], this.value ]; } } else { serializeObj[this.name] =
 * this.value; } }); return serializeObj; } }); })(jQuery);
 */